package com.dream.service.impl;

import com.dream.dao.BulletinDao;
import com.dream.dao.impl.BulletinDaoImpl;
import com.dream.pojo.Bulletin;
import com.dream.pojo.BulletinIdInformation;
import com.dream.service.BulletinService;
import com.dream.utils.DateUtil;

import java.util.List;

public class BulletinServiceImpl implements BulletinService {
    BulletinDao bulletinDao = new BulletinDaoImpl();

    @Override
    public int addBulletin(Bulletin bulletin) {
        return bulletinDao.addBulletin(bulletin);
    }

    @Override
    public List<Bulletin> list() {
        return bulletinDao.list();
    }

    @Override
    public Bulletin findById(long bulletinId) {
        return bulletinDao.findById(bulletinId);
    }

    @Override
    public long totalCount(String bulletinTitle, String userName, String startTime, String endTime) {
        startTime = DateUtil.formateLong2String(startTime);
        endTime = DateUtil.formateLong2String(endTime);
        return bulletinDao.totalCount(bulletinTitle,userName,startTime,endTime);
    }

    @Override
    public List<BulletinIdInformation> list(String bulltinTitle, String userName, String startTime, String endTime, long pageIndex, long pageSize) {
        startTime = DateUtil.formateLong2String(startTime);
        endTime = DateUtil.formateLong2String(endTime);
        return bulletinDao.list(bulltinTitle,userName,startTime,endTime,pageIndex,pageSize);
    }

    @Override
    public int updateReadCount(long bulletinId) {
        return bulletinDao.updateRedaCount(bulletinId);
    }

    @Override
    public int deleteById(Long bulletinId) {
        return bulletinDao.deleteById(bulletinId);
    }

    @Override
    public int updateBulletin(Bulletin bulletin) {
        return bulletinDao.updateBulletin(bulletin);
    }
}
